package com.ruoyi.help.utils;

import com.ruoyi.help.domain.Appointment;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

/**
 * @author lejav
 * @date 2023/5/20 10:28
 */
public class DateUtil {

    public static String getTime(Appointment appointment) {
        SimpleDateFormat inputDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
        inputDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8")); // 设置时区为中国时区
        Date date = new Date(); // 解析字符串为日期对象
        try {
            date = inputDateFormat.parse(appointment.getCreationTime().toString());
        } catch (ParseException e) {
            e.printStackTrace();
        }
        SimpleDateFormat outputDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        outputDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8"));

        return outputDateFormat.format(date);
    }
}
